<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .imgs {
        width: 600px;
        border: solid;
        display: flex;
        flex-direction: column;
      }
      .imgs .big {
      }
      .imgs .big img {
        width: 100%;
      }
      .imgs .small {
        display: flex;
        flex-wrap: nowrap;
      }

      .imgs .small > div {
        width: 100px;
        border: solid transparent;
        cursor: pointer;
      }
      .imgs .small > div:hover {
        border-color: black;
      }
      .imgs .small > div img {
        width: 100%;
      }
    </style>
  </head>
  <body>
    <div class="imgs">
      <div class="big">
        <img id="bigImg" src="./imgs/1.jpg" alt="" />
      </div>
      <div class="small">
        <div>
          <img data-thumb src="./imgs/1.jpg" alt="" />
        </div>
        <div>
          <img data-thumb src="./imgs/2.jpg" alt="" />
        </div>
        <div>
          <img data-thumb src="./imgs/3.jpg" alt="" />
        </div>
        <div>
          <img data-thumb src="./imgs/4.jpg" alt="" />
        </div>
        <div>
          <img data-thumb src="./imgs/5.jpg" alt="" />
        </div>
        <div>
          <img data-thumb src="./imgs/6.jpg" alt="" />
        </div>
      </div>
    </div>
    <script>
      const bigImg = document.getElementById("bigImg");
      // document.onclick = function (e) {
      document.onmouseover = function (e) {
        const target = e.target;
        const thumb = target.dataset.thumb;
        if (thumb !== undefined) {
          bigImg.src = target.src;
        }
      };
    </script>
  </body>
</html>
